<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加接种记录界面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }

        .admin-id {
            color: #9abcda;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form-item layui-form">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <h1>添加接种记录</h1>
            </div>
        </div>
        <hr>

<!--        <from class="layui-form">-->
            <div class="layui-form layuimini-form">
                <div class="layui-form-item">
                    <label class="layui-form-label required">接种用户ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="uid" lay-verify="required" lay-reqtext="接种用户ID不能为空"
                               placeholder="请输入接种用户ID"
                               value=""
                               class="layui-input" autocomplete="off">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">接种时间（年月日时分秒）</label>
                    <div class="layui-input-inline">

                        <input type="datetime-local" name="time" lay-verify="required" lay-reqtext="接种时间不能为空"
                               placeholder="请输入接种时间"
                               value=""
                               class="layui-input" autocomplete="off">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">接种剂次（一/二/三）</label>
                    <div class="layui-input-inline">
                        <input type="text" name="dose" lay-verify="required" lay-reqtext="接种剂次不能为空"
                               placeholder="请输入接种剂次"
                               value=""
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">接种单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="vacc_unit" lay-verify="required" lay-reqtext="接种单位不能为空"
                               placeholder="请输入接种单位"
                               value=""
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">生产企业</label>
                    <div class="layui-input-block">
                        <input type="text" name="enterprise" lay-verify="required" lay-reqtext="生产企业不能为空" placeholder="请输入生产企业"
                               value=""
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">疫苗批号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="batch_number" lay-verify="required" lay-reqtext="疫苗批号不能为空"
                               placeholder="请输入疫苗批号" value="" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认添加</button>
                    </div>
                </div>
            </div>
<!--        </from>-->

    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

        // 登录过期的时候，跳出ifram框架
        form.on('submit(saveBtn)', function (obj) {
            obj = obj.field;
            obj = {
                "uid": parseInt(obj.uid),
                "time": obj.time,
                "dose": obj.dose,
                "vacc_unit": obj.vacc_unit,
                "enterprise": obj.enterprise,
                "batch_number": obj.batch_number
            };
            console.log("看看对象");
            console.log(obj);
            console.log("看看JSON.stringify(obj)");
            console.log(JSON.stringify(obj));
            $.ajax({
                type: "POST",
                contentType: 'application/json',
                url: "http://110.42.199.36:8081/vaccination/insertVac",
                data: JSON.stringify(obj),
                dataType: 'json',
                success: function (data) {
                    console.log("成功");
                    console.log(data);
                    layer.alert('添加成功');
                }
            });
            return false;
        });


    });
</script>
</body>
</html>